using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace TTBox
{
    class UIUtility
    {
        static public void ChangeFace(Control arg_c, Color arg_cFore, Color arg_cBack)
        {
            if (arg_c.Name == "button_EM")
            {
                arg_c.BackColor = arg_cFore;
                return;
            }

            if (arg_c is SendAndWaitPanel)
                return;
            if (arg_c is BoxStatus)
                return;
            if (arg_c is Button)
            {
                arg_c.BackColor = Color.FromArgb(StoreData.getInstance().ButtonBackColor);
                arg_c.ForeColor = Color.FromArgb(StoreData.getInstance().ForeColor);
            }
            else if (arg_c is TextBox)
            {
                arg_c.BackColor = Color.FromArgb(StoreData.getInstance().BackColor);
                arg_c.ForeColor = Color.FromArgb(StoreData.getInstance().ForeColor);
            }
            else if (arg_c is Panel)
            {
                arg_c.BackColor = Color.FromArgb(StoreData.getInstance().PanelBackColor);
                arg_c.ForeColor = Color.FromArgb(StoreData.getInstance().ForeColor);
            }
            else if (arg_c is Label)
            {
                arg_c.ForeColor = Color.FromArgb(StoreData.getInstance().ForeColor);
                arg_c.BackColor = Color.FromArgb(StoreData.getInstance().PanelBackColor);
            }
            else if (arg_c is UserControl)
            {
                arg_c.BackColor = Color.FromArgb(StoreData.getInstance().PanelBackColor);
                arg_c.ForeColor = Color.FromArgb(StoreData.getInstance().ForeColor);
            }

            foreach (Control c in arg_c.Controls)
            {
                ChangeFace(c, arg_cFore, arg_cBack);
            }
        }
        static public void ChangeFaceX(Control arg_c,Color arg_cFore, Color arg_cBack)
        {
            if (arg_c.Name == "button_EM")
            {
                arg_c.BackColor = arg_cFore;
                return;
            }

            if (arg_c is SendAndWaitPanel)
                return;
            if (arg_c is BoxStatus)
                return;
            if (arg_c is Button)
            {
                arg_c.BackColor = arg_cBack;
                arg_c.ForeColor = arg_cFore;
            }
            else if (arg_c is TextBox)
            {
                arg_c.BackColor = arg_cBack;
                arg_c.ForeColor = arg_cFore;
            }
            else if (arg_c is Panel)
            {
                arg_c.BackColor = arg_cBack;
                arg_c.ForeColor = arg_cFore;
            }
            else if (arg_c is Label)
            {
                arg_c.ForeColor = arg_cFore;
                arg_c.BackColor = arg_cBack;
            }
            else if (arg_c is UserControl)
            {
                arg_c.BackColor = arg_cBack;
                arg_c.ForeColor = arg_cFore;
            }

            foreach (Control c in arg_c.Controls)
            {
                ChangeFace(c, arg_cFore, arg_cBack);
            }
        }

        static public void ButtonControl(Control arg_c, bool arg_b)
        {
            if (arg_c is Button)
            {
                arg_c.Enabled = arg_b;
            }
            foreach (Control c in arg_c.Controls)
            {
                ButtonControl(c, arg_b);
            }
        }

        

    }
}
